<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="../css/mui.min.css">
		<style type="text/css">
			.mui-bar{
				border: solid 1px aquamarine;
				border-radius: 5px 5px;
				margin: 1px 0;
				padding: 0 0;
			}
			.siftings{
				width: 25%;
				list-style: none;
				text-align: center;
				border-right: solid 1px aquamarine;
				line-height: 100%;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<li class="siftings mui-pull-left" sort="sales" value="0">销量<span class="mui-icon mui-icon-arrowthindown"></span></li>
			<li class="siftings mui-pull-left" sort="createtime" value="0">时间<span class="mui-icon mui-icon-arrowthindown"></span></li>
			<li class="siftings mui-pull-left" sort="displayorder" value="0">人气<span class="mui-icon mui-icon-arrowthindown"></span></li>
			<li class="siftings mui-pull-left" style="border: none;" sort="marketprice" value="0">价格<span class="mui-icon mui-icon-arrowthindown"></span></li>
		</header>
		<div class="mui-content">
		</div>
	</body>
	<script src="../js/avalon.js"></script>
	<script src="../js/mui.min.js"></script>
	<script type="text/javascript">
		//启用双击监听
		window.addEventListener('show',function(event){
			cid = event.detail.cid;
			api = event.detail.api;
			if(event.detail.api){
				api = event.detail.api;
			}else{
				api = 'CateGoods.getGoodsData';
			}
			mui.init({
				gestureConfig:{
					doubletap:true
				},
				subpages:[{
					url:'common_catesub.html',
					id:'common_catesub.html',
					styles:{
						top: '45px',
						bottom: '0px',
					},
					extras:{
						cateid:cid,
						api:api
					}
				}]
			});	
			
			/**
			 * 排序问题
			 * @param {String} sortType 排序类型
			 * @param {int} sortAD 升降序方式
			 */
			mui('header').on('tap','.siftings',function(){
				var sortType = this.getAttribute('sort');
				var sortAD = this.value;
				//将sortType sortAD 传入common_catesub 页面 并重新刷新
				var web = plus.webview.getWebviewById('common_catesub.html');
				var count = null,requestType=null,API=api;
				web.evalJS("getData("+cid+","+count+","+api+",'"+sortType+"','"+sortAD+"')");
				web.evalJS("document.getElementById('parentNode').setAttribute('sort','"+sortType+"')");
				web.evalJS("document.getElementById('parentNode').value="+sortAD);
				if(this.value==0){
					this.value=1;
				}else{
					this.value=0;
				}
			});
		});
		
		
		
		if(window.plus){
			plusReady();
		}else{
			document.addEventListener('plusready',plusReady);
		};
		
		var ws = null,wo = null;
		function plusReady(){
			ws = plus.webview.currentWebview();
			wo = ws.opener();
			plus.webview.show(ws,'pop-in');
			plus.nativeUI.closeWaiting();
			
			cid = ws.cid;
			api = ws.api;
			if(ws.api){
				api = ws.api;
			}else{
				api = 'CateGoods.getGoodsData';
			}
			//alert(api);
		};
		
		
		var contentWebview = null;
		document.querySelector('header').addEventListener('doubletap',function () {
			if(contentWebview==null){
				contentWebview = plus.webview.currentWebview().children()[0];
			}
			contentWebview.evalJS("mui('#pullrefresh').pullRefresh().scrollTo(0,0,100)");
		});
	</script>

</html>